#include "Comm.hpp"

int main()
{
    char buffer[1024];
    SetNonBlock(0);
    while (true)
    {
        ssize_t s = read(0, buffer, sizeof(buffer) - 1);
        if (s > 0)
        {
            buffer[s] = 0;
            std::cout << "Echo# " << buffer << std::endl;
        }
        else
        {
            if (errno == EAGAIN || EWOULDBLOCK)
            {
                std::cout << "底层数据未就绪，先干点别的" << std::endl;
                sleep(1);
                continue;
            }
            else if (errno == EINTR)
            {
                continue;
            }
            else
            {
                std::cout << "读取错误 s:" << s << " errno: " << errno << std::endl;
                sleep(1);
            }
        }
    }
}